<template>
  <div class="noAuth-box">
    <slot v-if="hasAuth"/>
    <div v-else>
      <el-result icon="warning" title="提示" subTitle="没有权限">
        <!-- <template slot="extra">
          <el-button type="primary" size="medium">返回</el-button>
        </template> -->
      </el-result>
    </div>
  </div>
</template>

<script>
  import {uploadImgDept} from '@/api/api'
  import { mapState, mapGetters } from 'vuex'
  export default {
    name: 'noAuth',
    props: {
      value: {
        // 绑定默认的value prop
        default: undefined
      },
      createFun: {
        type: Function
      }
    },
    data () {
      return {
        routeName: this.$route.name,
        // hasAuth: true,
      }
    },
    mounted() {
      if (this.hasAuth) {
        this.createFun()
      }
    },
    computed: {
      ...mapState({
        supperAdmin: state => state.user.supperAdmin,
      }),
      ...mapGetters(['userPageAuth']),
      hasAuth() {
        return true // noAuth组件暂时不启用，全部按照有权限处理
        if (this.supperAdmin) {
          return true
        } else {
          let routeName = this.$route.name
          if (this.userPageAuth.hasOwnProperty(routeName)) {
            if (this.userPageAuth[routeName]) {
              return true
            } else {
              return false
            }
          } else {
            return true
          }
        }
      },
    },
    methods: {
    },
  }
</script>

<style lang="scss" scoped>
</style>